<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
<head>
    <title></title>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" href="/End/Public/Admin/Css/bootstrap.css" />
    <link rel="stylesheet" type="text/css" href="/End/Public/Admin/Css/bootstrap-responsive.css" />
    <link rel="stylesheet" type="text/css" href="/End/Public/Admin/Css/style.css" />
    <script type="text/javascript" src="/End/Public/Admin/Js/jquery.js"></script>
    <script type="text/javascript" src="/End/Public/Admin/Js/jquery.sorted.js"></script>
    <script type="text/javascript" src="/End/Public/Admin/Js/bootstrap.js"></script>
    <script type="text/javascript" src="/End/Public/Admin/Js/ckform.js"></script>
    <script type="text/javascript" src="/End/Public/Admin/Js/common.js"></script>

 

    <style type="text/css">
        body {
            padding-bottom: 40px;
        }
        .sidebar-nav {
            padding: 9px 0;
        }

        @media (max-width: 980px) {
            /* Enable use of floated navbar text */
            .navbar-text.pull-right {
                float: none;
                padding-left: 5px;
                padding-right: 5px;
            }
        }
        .pages a,.pages span {
            display:inline-block;
            padding:2px 5px;
            margin:0 1px;
            border:1px solid #f0f0f0;
            -webkit-border-radius:3px;
            -moz-border-radius:3px;
            border-radius:3px;
        }
        .pages a,.pages li {
            display:inline-block;
            list-style: none;
            text-decoration:none; color:#58A0D3;
        }
        .pages a.first,.pages a.prev,.pages a.next,.pages a.end{
            margin:0;
        }
        .pages a:hover{
            border-color:#50A8E6;
        }
        .pages span.current{
            background:#50A8E6;
            color:#FFF;
            font-weight:700;
            border-color:#50A8E6;
        }


    </style>
</head>
<body>
<form class="form-inline definewidth m20" action="<?php echo U('Admin/index/indexUser','','');?>" method="post">
    用户名称：
    <input type="text" name="username" id="username"class="abc input-default" placeholder="" value="">&nbsp;&nbsp;  
    <button type="submit" class="btn btn-primary">查询</button>&nbsp;&nbsp; <button type="button" class="btn btn-success" id="addnew">新增用户</button>
</form>
<table class="table table-bordered table-hover definewidth m10">
    <thead>
    <tr>
        <th>用户id</th>
        <th>账号</th>
        <th>用户名</th>
        <th>邮箱</th>
        <th>最后登录时间</th>
        <th>状态</th>
        <th>操作</th>
    </tr>
    </thead>
        <?php if(is_array($list)): foreach($list as $key=>$vo): ?><tr>
                <td><?php echo ($vo["id"]); ?></td>
                <td><?php echo ($vo["account"]); ?></td>
                <td><?php echo ($vo["username"]); ?></td>
                <td><?php echo ($vo["email"]); ?></td>
                <td><?php echo ($vo["login_time"]); ?></td>
                <td>
                    <?php if(($vo['status']) == "1"): ?>正常
                        <?php else: ?>禁用<?php endif; ?>
                </td>
                <td>
                    <a href="<?php echo U('Admin/index/editUser',array('id'=>$vo['id']),'');?>" style="color:green ">编辑</a>&nbsp;&nbsp;
                    <a href="" onclick="del('<?php echo ($vo["id"]); ?>')" style="color:red ">删除</a>
                </td>
            </tr><?php endforeach; endif; ?>
    </tr>
</table>
    <div class="pages" style="float: right">
        <?php echo ($page); ?>
    </div>
</body>
</html>
<script>
    $(function () {
        

		$('#addnew').click(function(){

				window.location.href="<?php echo U('Admin/index/addUser','','');?>";
		 });


    });

	function del(id)
	{
		if(confirm("确定要删除吗？"))
		{
			var url = "<?php echo U('Admin/index/deluser');?>";
            $.ajax({
                url: url,   //请求后台地址
                type:"post",     //请求方式
                cache:true,    //控制是否缓存数据（post请求默认false，而get请求会为true,容易造成页面数据缓存问题）
                async:true,    //控制同步还是异步
                dataType:'json',
                data:{
                    id:id
                },   //传入参数
                success:function(data){
                    if(data=='1'){
                        window.location.reload();
                    }else
                    {
                        alert('删除失败，请重试！');
                    }
                }
            });

        }

	}
</script>